const KEY = 'user-key'
const store = localStorage
/**
 * 保存用户信息
 * @param {*} user
 */
export const saveUserToStore = user => {
	if (!user) {
		throw new Error('参数不能为空')
	}
	store.setItem(KEY, JSON.stringify(user))
}

/**
 * 获取用户信息
 */
export const getUserFromStore = () => {
	let userStr = store.getItem(KEY)
	return JSON.parse(userStr)
}

/**
 * 删除用户信息
 */
export const removeUserFromStore = () => {
	store.removeItem(KEY)
}
